﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ManageTicket.Human
{
    public partial class frmQuickSearchEmployee : Form
    {
        public frmQuickSearchEmployee(ArrayList arr)
        {
            InitializeComponent();
            arrSearchResult = arr;
        }

        ArrayList arrSearchResult;
        public ArrayList arrResult;
        Business.Department boDept = new Business.Department();

        private void frmQuickSearchEmployee_Load(object sender, EventArgs e)
        {
            lvwEmployee.Items.Clear();
            ListViewItem item;
            DataObjects.Department oDept;

            foreach (DataObjects.Employee oEmp in arrSearchResult)
            {
                item = new ListViewItem();
                item.Text = oEmp.EmployeeId;
                item.SubItems.Add(oEmp.LastName);
                item.SubItems.Add(oEmp.FirstName);
                oDept = boDept.GetObjectByPK(oEmp.DepartmentId);
                if (oDept != null)
                    item.SubItems.Add(oDept.DepartmentName);
                else
                    item.SubItems.Add("");

                lvwEmployee.Items.Add(item);
                lblCount.Text = "Tổng: " + lvwEmployee.Items.Count.ToString();
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            arrResult = new ArrayList();
            DataObjects.Employee oEmp;
            foreach (ListViewItem item in lvwEmployee.CheckedItems)
            {
                oEmp = new DataObjects.Employee();
                oEmp.EmployeeId = item.Text;
                oEmp.LastName = item.SubItems[1].Text;
                oEmp.FirstName = item.SubItems[2].Text;

                arrResult.Add(oEmp);
            }
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            arrResult = new ArrayList();
            this.Close();
        }
    }
}
